#include <iostream>
#include "Engine.h"
#include "Material.h"

#ifdef WIN32
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
#else
int main( int argc, char** argv )
#endif
{
    // cria a engine
    Engine& engine = Engine::getInstance();
    WindowSettings param;


    // "bate a chave" no motor
    param.argc = argc;
    param.argv = argv;

#ifdef WIN32
    ptr = hInstance;''
#endif

    if( !engine.init(param) )
        return 0;

    Material fundo;
    fundo.carregarTextura("deserto.jpg");
    //fundo.cor.a = 0.5f;
    fundo.transparente = false;



    Material m[4];
    m[1].carregarTextura("tank.png");
    m[1].usarMaterial();
    m[1].cor = Cor::COLOR_GREEN;

    m[2].carregarTextura("tank.png");
    m[2].usarMaterial();
    m[2].cor = Cor::COLOR_ORANGE;

    m[3].carregarTextura("tank.png");
    m[3].usarMaterial();
    m[3].cor = Cor::COLOR_CYAN;


    m[0].carregarTextura("tank.png");
    m[0].usarMaterial();


    for( int i=0; i<4; i++ )
    {
    	char tanque[32];
    	sprintf( &tanque[0], "tanque%d", i );
        Object& obj = engine.addObject( tanque );
        obj.setMaterial( &m[i] );

        obj.speed = 0;
        //obj.visible = i % 2;
        obj.posicao.x = -1.0 + 0.2*i + 0.1 ;
        obj.posicao.y = -1.0 + 0.2*i + 0.1;
        obj.tamanho.x = obj.tamanho.y = 0.2;
    }


    // laço principal
    engine.startGame();


    std::cout << "finalizando!" << std::endl;
    return 0;

}
